<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <link rel="stylesheet" href="<s:url value="/assets/css/main.css"></s:url>"/>
</head>
<style>
    body {
        background: #fff;
    }

    .yc {
        display: none;
    }

    p {
        margin-bottom: 20px;
    }

    .information2 {
        border: 1px solid #ccc;
        padding-top: 8px;
        padding-bottom: 8px;
        margin-bottom: 10px;
    }

    /* 记录 */
    .record{
        padding-bottom: 10px;
    }
    .record_caption {
        width: 500px;
        height: 60px;
        margin: 15px auto;
        display: flex;
        flex-flow: row nowrap;
    }
    .record_hr {
        width: 130px;
        height: 4px;
        background-color: #333;
        margin-top: 28px;
    }
    .caption_text {
        width: 240px;
        height: 60px;
        line-height: 60px;
        font-size: 25px;
        text-align: center;
        color: #333;
        font-weight: 500;
    }
    .allrecord{
        width: 100%;
    }
    .record {
        width: 100%;
        background-color: rgba(0, 0, 0, 0.03);
        margin-top: 20px;
    }
    .record_title {
        height: 40px;
        line-height: 40px;
        display: flex;
        flex-flow: row nowrap;
        text-align: left;
        background-color: rgba(0, 0, 0, 0.1);
        padding: 0 20px;
        margin-bottom: 20px;
    }
    .record_div {
        height: 40px;
        line-height: 20px;
        display: flex;
        flex-flow: row nowrap;
        text-align: left;
        padding: 0 20px;
    }
    .record_div2 {
        line-height: 20px;
        display: flex;
        flex-flow: row nowrap;
        text-align: left;
        padding: 0 20px;
    }
    .record_text1 {
        width: 110px;
    }
    .record_text2 {
        flex: 1;
    }
    .record_text3 {
        flex: 1;
        line-height: 20px;
        white-space: normal;
        word-break: break-all;
        word-wrap: break-word;
    }
    .record_text3 .download_text{
        margin-bottom: 10px;
    }
    .record_text3 .download_botton {
        display: inline-block;
        width: 60px;
        height: 25px;
        line-height: 25px;
        text-align: center;
        color: white;
        background-color: #0e84ff;
        border-radius: 5px;
        margin-left: 20px;
        cursor: pointer;
    }
</style>
<body>
<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>

<form:form commandName="taskMain" cssClass="form-horizontal" role="form" onsubmit="return false;"
           enctype="multipart/form-data" id="updateForm">

    <div class="row">
        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">任务名称</label>
            <div class="col-sm-9">
                <input type="text" value="${taskMain.mainName}" class="form-control" readonly>
            </div>
        </div>
        <c:if test="${not empty taskMain.content}">
            <div class="form-group">
                <label class="control-label col-sm-offset-1 col-sm-1">任务内容</label>
                <div class="col-sm-9">
                    <input type="text" value="${taskMain.content}" class="form-control" readonly>
                </div>
            </div>
        </c:if>

        <c:if test="${not empty taskRank.evaluations}">
            <div class="form-group">
                <label class="control-label col-sm-offset-1 col-sm-1">本轮督办评价</label>
                <div class="col-sm-9">
                    <input type="text" value="${taskRank.evaluations}" class="form-control" readonly>
                </div>
            </div>
        </c:if>


        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">子事项</label>
            <div class="col-sm-9">
                <input type="text" value="${taskUnit.taskSubName}" class="form-control" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">攻坚任务附件:</label>
            <div class="col-sm-9">
                <c:if test="${not empty taskMain.gJFile}">
                    <c:forEach items="${taskMain.gJFile}" var="fileMap">
                        <div style="margin-bottom:15px;">
                            <input style="width: 70%;" type="text" class="fileName" readonly
                                   title="${fileMap.fileName}"
                                   value="${fileMap.fileName}" onclick="copyFile(this)">
                            <button class="btn btn-primary file" onclick="download(this)"
                                    FileSysId="${fileMap.file}">
                                下载附件
                            </button>
                        </div>
                    </c:forEach>
                </c:if>
                <c:if test="${empty taskMain.gJFile}">
                    <input type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                </c:if>
            </div>
        </div>
            <%--<div class="form-group">--%>
            <%--<label class="control-label col-sm-1 no-padding-right">任务附件</label>--%>
            <%--<c:if test="${not empty taskMain.files}">--%>
            <%--<c:forEach items="${taskMain.files}" var="fileMap">--%>
            <%--${fileMap.file}--%>
            <%--</c:forEach>--%>
            <%--&lt;%&ndash;<div class="col-sm-8">&ndash;%&gt;--%>
            <%--&lt;%&ndash;<input type="text" readonly value="${taskMain.fileName}">&ndash;%&gt;--%>
            <%--&lt;%&ndash;<button class="btn btn-success" FileSysId ="${taskMain.file}" onclick="download(this)"><span&ndash;%&gt;--%>
            <%--&lt;%&ndash;class="glyphicon glyphicon-save"></span>下载附件&ndash;%&gt;--%>
            <%--&lt;%&ndash;</button>&ndash;%&gt;--%>
            <%--&lt;%&ndash;</div>&ndash;%&gt;--%>
            <%--</c:if>--%>
            <%--<c:if test="${empty taskMain.file}">--%>
            <%--<div class="col-sm-8">--%>
            <%--<input type="text" value="无任务附件" class="form-control" readonly>--%>
            <%--</div>--%>
            <%--</c:if>--%>
            <%--</div>--%>
            <%--循环附件下载--%>
        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">附件:</label>
            <div class="col-sm-9">
                <c:if test="${not empty taskMain.files}">
                    <c:forEach var="file" items="${taskMain.files}" >
                        <c:if test="${fn:contains(file['file'],'http')==false}">
                            <c:forEach items="${taskMain.files}" var="fileMap">
                                <div style="margin-bottom:15px;">
                                    <input style="width: 70%;" type="text" class="fileName" readonly title="${fileMap.fileName}"
                                           value="${fileMap.fileName}" onclick="copyFile(this)">
                                    <button class="btn btn-primary file" onclick="download(this)" FileSysId="${fileMap.file}">
                                        下载附件
                                    </button>
                                </div>
                            </c:forEach>
                        </c:if>
                        <c:if test="${fn:contains(file['file'],'http')==true}">
                            <c:forEach items="${taskMain.files}" var="fileMap">
                                <div style="margin-bottom:15px;">
                                    <input style="width: 70%;" type="text" class="fileName" readonly title="${fileMap.fileName}"
                                           value="${fileMap.fileName}">
                                    <button class="btn btn-primary file downLoadFile" onclick="downLoadFile('${fileMap.file}')">
                                        下载附件
                                    </button>
                                </div>
                            </c:forEach>
                        </c:if>
                    </c:forEach>
                </c:if>
                <c:if test="${empty taskMain.files}">
                    <input type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                </c:if>
            </div>
        </div>
            <%-----以上为附件下载----%>
        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">牵头单位</label>
            <div class="col-sm-9">
                <input type="text" value="${leadDepts}" class="form-control" readonly>
            </div>
        </div>
        <c:forEach items="${xbDeptList}" var="xbDept">
            <div class="form-group">
                <label class="control-label col-sm-offset-1 col-sm-1">协办单位</label>
                <c:if test="${taskUnit.unitType !='1'}">
                    <div class="col-sm-9">
                        <input type="text" value="${xbDept.deptName}" class="form-control" readonly>
                    </div>
                </c:if>
                <c:if test="${taskUnit.unitType=='1'}">
                    <div class="col-sm-6">
                        <input type="text" value="${xbDept.deptName}" class="form-control" readonly>
                    </div>
                    <div class="col-sm-2">
                        <button class="btn btn-sm btn-info assist" taskUnitSysId="${xbDept.sysId}">查看</button>
                        <button class="btn btn-sm btn-info urge" taskUnitSysId="${xbDept.sysId}">催办</button>
                    </div>
                </c:if>
            </div>
        </c:forEach>
        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">已反馈单位</label>
            <div class="col-sm-9">
                <input type="text" value="${feedBacks}" class="form-control" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">未反馈单位</label>
            <div class="col-sm-8">
                <input type="text" value="${noFeedBacks}" class="form-control" readonly>
            </div>
        </div>
    </div>
    <c:if test="${!empty leaderMessages}">
        <h3 class="col-sm-offset-5">领导批示信息</h3>
        <c:forEach items="${leaderMessages}" var="leaderMessage">
            <div class="form-group">
                <label class="control-label col-sm-offset-1 col-sm-1">姓名:</label>
                <div class="col-sm-4">
                    <input type="text" value="${leaderMessage.createUserName}" class=" col-sm-3 form-control" readonly>
                </div>
                <label class="control-label col-sm-1">时间:</label>
                <div class="col-sm-4">
                    <input type="text" value="${leaderMessage.createDate} ${leaderMessage.createTime}"
                           class=" col-sm-3 form-control" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-offset-1 col-sm-1">批示信息:</label>
                <div class="col-sm-9">
                                <textarea rows="3" readonly class="form-control FeedbackContent"
                                          type="text"
                                          style="resize: vertical;min-height: 50px">${leaderMessage.content}</textarea>
                </div>
            </div>
        </c:forEach>
    </c:if>

    <c:if test="${empty taskBackNewList}">
        <h3 class="col-sm-offset-5">反馈内容</h3>

        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">反馈状态:</label>
            <div class="col-sm-4">
                <label class="control-label">未反馈</label>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">办理情况:</label>
            <div class="col-sm-9">
                                <textarea rows="3" FeedbackContent="#FeedbackContent1" readonly class="form-control"
                                          type="text" style="resize: vertical;min-height: 50px"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">存在问题:</label>
            <div class="col-sm-9">
                            <textarea rows="3" onclick="FeedbackContent(this)" FeedbackContent="#FeedbackContent2"
                                      readonly class="form-control"
                                      type="text" style="resize: vertical;min-height: 50px"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-offset-1 col-sm-1">下一步计划:</label>
            <div class="col-sm-9">
                            <textarea rows="3" readonly onclick="FeedbackContent(this)"
                                      FeedbackContent="#FeedbackContent3" class="form-control"
                                      type="text" style="resize: vertical;min-height: 50px"></textarea>
            </div>
        </div>
    </c:if>
    <c:if test="${!empty taskBackNewList}">
        <h3 class="col-sm-offset-5">反馈内容</h3>
        <c:forEach var="taskBackNew" items="${taskBackNewList}">
            <div class="row">
                <div class="form-group">
                    <label class="control-label col-sm-offset-1 col-sm-1">反馈单位1:</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" value="${taskBackNew.deptName}" readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-offset-1 col-sm-1">反馈人:</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" value="${taskBackNew.senderName}" readonly>
                    </div>
                    <label class="control-label col-sm-1">反馈时间:</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control"
                               value="${taskBackNew.createDate} ${taskBackNew.createTime}" readonly>
                    </div>
                </div>
                <div class="form-group">
                        <%--<label class="control-label col-sm-offset-1 col-sm-1">附件:</label>--%>
                        <%--<div class="col-sm-4">--%>
                        <%--<c:if test="${not empty taskBackNew.file}">--%>
                        <%--<input type="text" readonly value="${taskBackNew.fileName}">--%>
                        <%--<button class="btn btn-primary" FileSysId="${taskBackNew.file}" onclick="download(this)">--%>
                        <%--下载附件--%>
                        <%--</button>--%>
                        <%--</c:if>--%>
                        <%--<c:if test="${empty taskBackNew.file}">--%>
                        <%--<input type="text" value="无附件" class=" col-sm-3 form-control" readonly>--%>
                        <%--</c:if>--%>
                        <%--</div>--%>
                    <label class="control-label col-sm-offset-1 col-sm-1">反馈状态:</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control"
                               value="${taskBackNew.status == 0 ? "未处理" :taskBackNew.status == 1 ? "办结" : taskBackNew.status == 2 ? "退回重办" : taskBackNew.status == 3 ? "已反馈" : "未知"}"
                               readonly>
                    </div>
                </div>
                    <%--循环附件下载--%>
                <div class="form-group">
                    <label class="control-label col-sm-offset-1 col-sm-1">附件:</label>
                    <div class="col-sm-9">
                        <c:if test="${not empty taskBackNew.files}">
                            <c:forEach items="${taskBackNew.files}" var="fileMap">
                                <div style="margin-bottom:15px;">
                                    <input style="width: 70%;" type="text" class="fileName" readonly
                                           title="${fileMap.fileName}"
                                           value="${fileMap.fileName}" onclick="copyFile(this)">
                                    <button class="btn btn-primary file" onclick="download(this)"
                                            FileSysId="${fileMap.file}">
                                        下载附件
                                    </button>
                                </div>
                            </c:forEach>
                        </c:if>
                        <c:if test="${empty taskBackNew.files}">
                            <input type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                        </c:if>
                    </div>
                </div>
                    <%-----以上为附件下载----%>
                <div class="form-group">
                    <label class="control-label col-sm-offset-1 col-sm-1">办理情况:</label>
                    <div class="col-sm-9">
                                <textarea rows="3" onclick="FeedbackContent(this)" FeedbackContent="#FeedbackContent1"
                                          readonly class="form-control"
                                          type="text"
                                          style="resize: vertical;min-height: 50px">${taskBackNew.content}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-offset-1 col-sm-1">存在问题:</label>
                    <div class="col-sm-9">
                            <textarea rows="3" onclick="FeedbackContent(this)" FeedbackContent="#FeedbackContent2"
                                      readonly class="form-control"
                                      type="text"
                                      style="resize: vertical;min-height: 50px">${taskBackNew.problem}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-offset-1 col-sm-1">下一步计划:</label>
                    <div class="col-sm-9">
                            <textarea rows="3" readonly onclick="FeedbackContent(this)"
                                      FeedbackContent="#FeedbackContent3" class="form-control"
                                      type="text"
                                      style="resize: vertical;min-height: 50px">${taskBackNew.plan}</textarea>
                    </div>
                </div>
                <c:if test="${taskBackNew.status == 3}">
                    <div class="form-group" id="zhuangtai">
                        <label class="col-sm-offset-2 control-label col-sm-1">是否办结:</label>
                        <div class="col-sm-2">
                            <select class="form-control zt" onchange="sfbanjie(this)">
                                <option value=" ">点击选择</option>
                                <option value="1">办结</option>
                                <option value="2">退回重办</option>
                                    <%--<option value="3">提请领导审阅是否办结</option>--%>
                            </select>
                        </div>
                        <label class="control-label col-sm-1 yc">评价:</label>
                        <div class="col-sm-2 yc">
                            <select class="form-control hg" onchange="hege(this)">
                                <option value="1">好</option>
                                <option value="2">中</option>
                                <option value="2">差</option>
                            </select>
                        </div>
                    </div>
                    <c:if test="${taskUnit.timeType == 2}">
                        <div class="form-group timeTypeDiv" style="display: none">
                            <div class="col-sm-offset-3 col-sm-5">
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="1" class="timeType">是否结束周期性任务
                                </label>
                            </div>
                        </div>
                    </c:if>
                    <div class="row updataBackNew">
                        <div class="col-sm-offset-8 col-sm-4">
                            <button class="btn btn-sm btn-info" taskBackNewSysId="${taskBackNew.sysId}"
                                    id="updataBackNew">
                                确定
                            </button>
                        </div>
                    </div>
                </c:if>
            </div>
            <hr/>
        </c:forEach>
    </c:if>



    <input type="hidden" class="taskMainId" value="${taskSub.taskMainId}">
</form:form>


<div class="record_caption">
    <div class="record_hr"></div>
    <div class="caption_text">本轮督办反馈记录</div>
    <div class="record_hr"></div>
</div>
<div class="allrecord"></div>


<!-- footer -->

<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<%--多选上传--%>

<script src="<s:url value="/assets/js/chosen.jquery.js"></s:url>"></script>
<script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>
<script src="<s:url value="/assets/js/modal/modal.js"></s:url>"></script>
<script src="<s:url value="/assets/js/own.js"></s:url>"></script>


</body>



<%--督办单位反馈记录--%>
<script>
    function orderSort(attr) {
        return function (obj1, obj2) {
            var value1 = obj1[attr];
            var value2 = obj2[attr];
            if (!isNaN(Number(value1)) && !isNaN(Number(value2))) {
                var val1 = Number(value1);
                var val2 = Number(value2);
                value1 = val1;
                value2 = val2;
            }
            if (value1 > value2) {
                return -1;
            } else if (value1 < value2) {
                return 1;
            } else {
                return 0;
            }
        };
    }
    // 参数先写死
    // var specialTask_taskMainId = document.getElementById("specialTask_taskMainId").value
    // var specialTask_timeRound = document.getElementById("specialTask_timeRound").value
    //请求攻坚反馈信息接口
    $.ajax({
        url:'/taskMain/historyDuBan?taskMainId=20210326100000000772&timeRound=1',
        dataType:'json',
        type:'get',
        contentType:'application/json',
        success:function (res) {
            var html="";
            var dataArr = []
            for (let i = 0; i < res.data.length; i++) {
                dataArr.push({
                    time:res.data[i].createDate + " " + res.data[i].createTime,
                    content:res.data[i].content,
                    problem:res.data[i].problem,
                    plan:res.data[i].plan,
                    fileDto:res.data[i].fileDto,
                })
            }
            var newdata =  dataArr.sort(orderSort("time"))
            var html = ""
            for (let i = 0; i < newdata.length; i++) {
                let file_div = ""
                if(newdata[i].fileDto == ""||newdata[i].fileDto==undefined||newdata[i].fileDto==null){
                    file_div = '<div class="download_text"> 无</div>'
                }else{
                    for (let j = 0; j < newdata[i].fileDto.length; j++) {
                        file_div += '<div class="download_text"> ' +
                            '<input type="hidden" class="xiazaiwenjianid" value="'+ newdata[i].fileDto[j].fileId +'"> ' +
                            '<a href="javascript:;"  style="display: inline-block;width: 150px;"  class="xiazaiwenjianming">'+newdata[i].fileDto[j].fileName+'</a>' +
                            '<div class="download_botton xiazaiwenjiananniu">下载</div>' +
                            '</div>'
                    }
                }
                html +=  '<div class="record">'+
                    '<div class="record_title">'+
                    '<div class="record_text1">反馈时间：</div>'+
                    '<div class="record_text2">'+(newdata[i].time?newdata[i].time:"")+'</div>'+
                    '</div>'+
                    '<div class="record_div">'+
                    '<div class="record_text1">办理情况：</div>'+
                    '<div class="record_text3">'+(newdata[i].content?newdata[i].content:"")+'</div>'+
                    '</div>'+
                    '<div class="record_div">'+
                    '<div class="record_text1">存在问题：</div>'+
                    '<div class="record_text3">'+(newdata[i].problem?newdata[i].problem:"")+'</div>'+
                    '</div>'+
                    '<div class="record_div">'+
                    '<div class="record_text1">下步计划：</div>'+
                    '<div class="record_text3">'+(newdata[i].plan?newdata[i].plan:"")+'</div>'+
                    '</div>'+
                    '<div class="record_div2">'+
                    '<div class="record_text1">附件下载：</div>'+
                    '<div class="record_text3">'+
                    file_div +
                    '</div>'+
                    '</div>'+
                    '</div>'
            }
            var allrecord = document.querySelector(".allrecord")
            allrecord.innerHTML = html
            var xiazaiwenjianid = document.querySelectorAll(".xiazaiwenjianid")
            var xiazaiwenjianming = document.querySelectorAll(".xiazaiwenjianming")
            var xiazaiwenjiananniu = document.querySelectorAll(".xiazaiwenjiananniu")
            for (let i = 0; i < xiazaiwenjiananniu.length; i++) {
                xiazaiwenjiananniu[i].onclick = function(){
                    window.open('/filesUpload/download?id='+xiazaiwenjianid[i].value+'&name='+xiazaiwenjianming[i].innerText)
                }
            }

        }
    });
</script>


</html>